//
//  AccountAndSafetyViewController.m
//  ChatDemo-UI2.0
//
//  Created by Sylar on 16/8/17.
//  Copyright © 2016年 Sylar. All rights reserved.
//

#import "AccountAndSafetyViewController.h"
#import "SY_Setting_MakeSurePhoneNumViewController.h"
#import "SY_Setting_PassWordViewController.h"

@interface AccountAndSafetyViewController ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
{
    NSArray *titleArr;
}

@property (nonatomic, strong) UITableView *myTable;

@end

@implementation AccountAndSafetyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.navBar.nav_titleLabel.text = @"账户与安全";
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view setBackgroundColor:RGBCOLOR(240,239,245)];
    
    titleArr = @[@"修改密码",@"更改手机号"];
    
    [self.view addSubview:self.myTable];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITabelViewDataSource & UITabelViewDelegate

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
    
    if (cell == nil) {
        cell  = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"identifier"];
        
    }
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 200, 44)];
    [titleLabel setFont:[UIFont systemFontOfSize:15]];
    [titleLabel setTextColor:RGBCOLOR(59, 59, 59)];
    titleLabel.text = [titleArr objectAtIndex:indexPath.row];
    [cell.contentView addSubview:titleLabel];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(15, 43.5, SCREENWIDTH, 0.5)];
    [lineView setBackgroundColor:colorFromHex(@"#DEDEDE")];
    [cell.contentView addSubview:lineView];
    
    if (indexPath.row == 1) {
        lineView.x = 0;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.row == 0) {
        SY_Setting_MakeSurePhoneNumViewController *mkVC = [[SY_Setting_MakeSurePhoneNumViewController alloc]init];
        mkVC.typeNum = @"1";
        [self.navigationController pushViewController:mkVC animated:YES];
        
    }else if (indexPath.row == 1) {
        //mkVC.typeNum = @"2";
        
        SY_Setting_PassWordViewController *pwVC =[[SY_Setting_PassWordViewController alloc]init];
        
        [self.navigationController pushViewController:pwVC animated:YES];
    }
    
}

#pragma mark - Get
- (UITableView *)myTable {
    if (_myTable == nil) {
        _myTable = [[UITableView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHeight, SCREENWIDTH, 88) style:(UITableViewStylePlain)];
        _myTable.delegate = self;
        _myTable.dataSource = self;
        _myTable.rowHeight = 44;
        _myTable.separatorStyle = UITableViewCellSeparatorStyleNone;
        _myTable.scrollEnabled = NO;
    }
    return _myTable;
}


@end
